//
//  QCSystemCheckController.swift
//  爱汽车
//
//  Created by liujianlong on 2023/8/24.
//

import UIKit
import TCCKit

class QCSystemCheckController: QCViewController {
    var array = ["手动自检","自动自检"]
    override func viewDidLoad() {
        super.viewDidLoad()
        initUI()
    }
    
    override func initUI() {
        title = LS("系统自检")
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(QCSettingCell.nib(), forCellReuseIdentifier: QCSettingCell.ID())
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
}
//MARK: - UITableViewDataSource
extension QCSystemCheckController:UITableViewDataSource
{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return array.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: QCSettingCell.ID()) as! QCSettingCell
        cell.img.image = UIImage(named: array[indexPath.row])
        cell.title.text = LS(array[indexPath.row])
        return cell
    }
}
//MARK: - UITableViewDelegate
extension QCSystemCheckController:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let hex = array[indexPath.row] == "手动自检" ? "01" : "00"
        let title = hex == "00" ? "是否进行自动检测" : "是否进行手动检测"
         let vc = QCAlertPopViewController(useXib: true)
        vc.show(title,"否","是")
        vc.rightBtnBlock = {
            CCHud.start(LS("请稍后..."))
            BLEData.appSetDataToPer(AIQC.systemCheckStart.cmd, hex).write
        }
//        CCHud.start("")
//        let vc = QCCheckController()
//        vc.style = array[indexPath.row] == "手动自检" ? .manaul : .auto
//        push(vc,true)
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 0
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return nil
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return nil
    }
}
